<template>
  <div class="box">
    <h2>Son1子组件</h2>
    从vuex中获取的值：<label>{{ count }}</label>
    <br>
    <button @click="addCount(1)">值 + 1</button>
    <button @click="addCount(5)">值 + 5</button>
    <button @click="addCount(10)">值 + 10</button>
    <button @click="changeCountAsync(888)">一秒后修改成888</button>
    <button @click="changeTitle('还有101集')">改标题</button>
    <hr>
    <div>{{ filterList }}</div>
    <hr>
    <div>{{ user.userInfo.name }}</div>
    <div>{{ setting.theme }}</div>
    <div>{{ userInfo }}</div>
    <button @click="setUser({name:'xiaoli', age:80})">更新个人信息</button>
    <button @click="setUserSecond({name: 'li',age: 18})">一秒后更新信息</button>
    <div>{{ theme }}--{{ desc }}</div>
    <button @click="setTheme('skyblue')">更新主题</button>
    <hr>
    <div>{{ UpperCaseName }}</div>
  </div>
</template>

<script>
import { mapState, mapMutations, mapActions, mapGetters } from 'vuex'
export default {
  name: 'Son1Com',
  computed: {
    ...mapState(['count', 'title', 'user', 'setting']),
    ...mapState('user', ['userInfo']),
    ...mapState('setting', ['theme', 'desc']),
    ...mapGetters(['filterList']),
    ...mapGetters('user', ['UpperCaseName'])
  },
  methods: {
    ...mapMutations(['addCount', 'changeTitle']),
    ...mapActions(['changeCountAsync']),
    // 分模块的映射
    ...mapMutations('setting', ['setTheme']),
    ...mapMutations('user', ['setUser']),
    ...mapActions('user', ['setUserSecond'])
  }
}
</script>

<style lang="css" scoped>
.box{
  border:3px solid #ccc;
  width: 400px;
  padding: 10px;
  margin: 20px;
}
h2{
  margin-top:10px ;
}

</style>
